]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
shell-global: Add shell_get_self_contact_features
authorJasper St. Pierre <jstpierre@mecheye.net>
Sat, 26 Feb 2011 14:23:38 +0000 (09:23 -0500)
committerJasper St. Pierre <jstpierre@mecheye.net>
Mon, 14 Mar 2011 22:48:18 +0000 (18:48 -0400)
This is another workaround for the lack of gjs supporting array
arguments, this time wrapping tp_connection_upgrade_contacts to
add new features to the connection's self contact.

https://bugzilla.gnome.org/show_bug.cgi?id=642793

src/shell-global.c
src/shell-global.h

index b16758ff51c50c86010a09cafddbb87eba585181..67c870325698b6b8f8d1e7e9288025c31704a493 100644 (file)
@@ -2048,3 +2048,43 @@ shell_global_launch_calendar_server (ShellGlobal *global)
 
   g_free (calendar_server_exe);
 }
+
+static void
+shell_global_get_self_contact_features_cb (TpConnection *connection,
+                                           guint n_contacts,
+                                           TpContact * const *contacts,
+                                           const GError *error,
+                                           gpointer user_data,
+                                           GObject *weak_object)
+{
+  if (error != NULL) {
+    g_print ("Failed to upgrade self contact: %s", error->message);
+    return;
+  }
+  ((ShellGetSelfContactFeaturesCb)user_data)(connection, *contacts);
+}
+
+/**
+ * shell_get_self_contact_features:
+ * @self: A connection, which must be ready
+ * @n_features: Number of features in features
+ * @features: (array length=n_features) (allow-none) (element-type uint):
+ *  Array of features
+ * @callback: (scope async): User callback to run when the contact is ready
+ * 
+ * Wrap tp_connection_upgrade_contacts due to the lack of support for
+ * proper arrays arguments in GJS.
+ */
+void
+shell_get_self_contact_features (TpConnection *self,
+                                 guint n_features,
+                                 const TpContactFeature *features,
+                                 ShellGetSelfContactFeaturesCb callback)
+{
+  TpContact *self_contact = tp_connection_get_self_contact (self);
+
+  tp_connection_upgrade_contacts (self, 1, &self_contact,
+                                  n_features, features,
+                                  shell_global_get_self_contact_features_cb,
+                                  callback, NULL, NULL);
+}
index 42909801c02f137f3ba2fd1340f0327f6034193c..b3f86e398570f54a818f6143530a3af3c9ff3fab 100644 (file)
@@ -157,6 +157,14 @@ void shell_get_tp_contacts (TpConnection *self,
 
 void shell_global_launch_calendar_server (ShellGlobal *global);
 
+typedef void (*ShellGetSelfContactFeaturesCb) (TpConnection *connection,
+                                               TpContact *contact);
+
+void shell_get_self_contact_features (TpConnection *self,
+                                      guint n_features,
+                                      const TpContactFeature *features,
+                                      ShellGetSelfContactFeaturesCb callback);
+
 G_END_DECLS
 
 #endif /* __SHELL_GLOBAL_H__ */